
public final class TestSync {
	
	final Object mSync = new Object();
	
	private void test1(int id) {
		synchronized (mSync) {
			for (int i = 0; i < 10; i++) {
				System.out.println("" + id + " TestSync.test1()" + i);
				
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}
	
	private void test11() {
		synchronized (mSync) {
			test1(1202);
		}
	}
	
	private void test12() {
		new Thread(new Runnable() {
			
			@Override
			public void run() {

				synchronized (mSync) {
					test1(2222);
				}
			}
		}).start();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		TestSync sync = new TestSync();
		
		sync.test12();
		sync.test11();
	}

}
